package org.bpm.utils
{
	import flash.display.MovieClip;
	import flash.utils.getDefinitionByName;
	
	import org.bpm.interfaces.IMapElement;
	import org.bpm.view.ArrowMovieClip;
	import org.bpm.view.DefaultMapElement;
	import org.bpm.view.NodeMovieClip;

	/**
	 * This class packages the functionality of create a view from ui.swc with requested type.
	 * */
	public class UIGenerator
	{
		public function UIGenerator()
		{
		}
		public function getUI(pType:String):IMapElement{
			var cl:Class;
			try{
				cl = getDefinitionByName(pType) as Class;
				if(pType=="arrow") return new ArrowMovieClip(new cl());
				return new NodeMovieClip(new cl());
			}catch(e:Error){
				return new DefaultMapElement();
			}
			return null;
		}
	}
}